<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center changePwdPhone_flex_0"
			:style="{height:(64+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub changePwdPhone_fd0_0'>
				<view class='flex flex-wrap align-center changePwdPhone_fd0_0_c2' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  changePwdPhone_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-center flex-sub'>
					<text class='changePwdPhone_fd0_0_c1_c0'>修改密码</text>
				</view>
				<view class='flex flex-wrap align-center changePwdPhone_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (64+StatusBarRpx)+'rpx'}"></view>

		<view class="flex flex-direction flex-wrap align-stretch changePwdPhone_flex_1">
			<view class='flex flex-wrap align-center changePwdPhone_fd1_0'>
				<text class='changePwdPhone_fd1_0_c0'>新密码</text>
				<input class='flex-sub changePwdPhone_fd1_0_c1' type="text" :focus='true' placeholder="请输入新密码"
					confirm-type="done" :maxlength="12" :password='true' placeholder-style="color:#999;font-size:20rpx"
					v-model="newPassword" />
			</view>
			<view class='flex flex-wrap align-center changePwdPhone_fd1_1'>
				<text class='changePwdPhone_fd1_1_c0'>确认新密码</text>
				<input class='flex-sub changePwdPhone_fd1_1_c1' type="text" :focus='true' placeholder="请再次输入新密码"
					confirm-type="done" :maxlength="12" :password='true' placeholder-style="color:#999;font-size:20rpx"
					v-model="confirmPassword" />
			</view>
		</view>

		<view class="flex flex-direction flex-wrap align-center benben-position-layout flex changePwdOldCode_flex_2" @tap.stop="codeResetPasswordFunc()">
			<button class='changePwdOldCode_fd2_0'>完成</button>
		</view>

	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"newPassword": "",
				"confirmPassword": "",
				"phone": "",
				"code": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				phone,
				code
			} = options
			if (phone !== undefined) this.phone = phone
			if (code !== undefined) this.code = code
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//验证码重置密码
			async codeResetPasswordFunc() {
				if (!validate(this.newPassword, 'require')) {
					this.$message.info('请输入新密码');
					return false;
				}
				if (!validate(this.newPassword, 'password')) {
					this.$message.info('请输入6-12位字母+数字新密码');
					return false;
				}
				if (!validate(this.confirmPassword, 'require')) {
					this.$message.info('请输入确认新密码');
					return false;
				}
				if (!(this.newPassword == this.confirmPassword)) {
					this.$message.info('两次密码输入不一致');
					return false;
				}
				//请求方法
				//数据验证

				let data5caeeba9866aa = await this.$api.post(global.apiUrls.post5caeeba9866aa, {
					password: this.newPassword,
					account: this.phone,
					code: this.code,
					type: '7',
					account_type: 'mobile'
				});

				if (data5caeeba9866aa.data.code != 1) {
					this.$message.info(data5caeeba9866aa.data.msg);
					return
				}
				this.$message.info('修改成功');
				this.$store.commit('logout')
				setTimeout(() => {
					uni.reLaunch({
						url: '/pages/tabBar/login/login'
					})
				}, 800)
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto !important;
	}

	.changePwdPhone_flex_0 {
		background: #fff;
		width: 100%;
		height: 64rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.changePwdPhone_fd0_0_c2 {
		width: 50rpx;
		height: 50rpx;
	}

	.changePwdPhone_fd0_0_c1_c0 {
		font-size: 25rpx;
		font-weight: 500;
		color: #333;
		line-height: 64rpx;
	}

	.changePwdPhone_fd0_0_c0_c0 {
		font-size: 25rpx;
		font-weight: 500;
		color: #333;
	}

	.changePwdPhone_fd0_0 {
		margin: 0rpx 25rpx 0rpx 25rpx;
	}

	.changePwdPhone_flex_1 {
		background: #fff;
		font-size: 20rpx;
		background-size: 100% auto !important;
		padding: 0rpx 25rpx 0rpx 25rpx;
		border-radius: 10rpx;
		margin: 16rpx 25rpx 0rpx 25rpx;
	}

	.changePwdPhone_fd1_2 {
		background: rgba(205, 150, 45, 1);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		font-size: 32rpx;
		color: #fff;
		margin: 80rpx 0rpx 0rpx 0rpx;
		height: 80rpx;
		line-height: 88rpx;
		width: 686rpx;
	}

	.changePwdPhone_fd1_1_c1 {
		// line-height: 48rpx;
		font-size: 20rpx;
		font-weight: 400;
		color: #333;
	}

	.changePwdPhone_fd1_1_c0 {
		font-size: 20rpx;
		font-weight: 400;
		font-style: normal;
		color: #333;
		width: 135rpx;
		line-height: 48rpx;
	}

	.changePwdPhone_fd1_1 {
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.changePwdPhone_fd1_0_c1 {
		// line-height: 45rpx;
		font-size: 20rpx;
		font-weight: 400;
		color: #333;
	}

	.changePwdPhone_fd1_0_c0 {
		font-size: 20rpx;
		font-weight: 400;
		font-style: normal;
		color: #333;
		width: 135rpx;
	}

	.changePwdPhone_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 20rpx 0rpx 20rpx 0rpx;
	}
	
	.changePwdOldCode_flex_2 {
		width: 100%;
		// height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		padding: 0 25rpx 35rpx;
	}
	
	.changePwdOldCode_fd2_0 {
		background: #4087FD;
		border-radius: 34rpx;
		font-size: 32rpx;
		color: #fff;
		width: 100%;
		height: 68rpx;
		line-height: 68rpx;
		font-size: 25rpx;
		font-weight: 500;
	}
</style>